Ios gestures are interesting. ios gestures are interesting.Ios gestures are very interesting.I. Overview
For iPhone touch screen processing, before 3.2UIResponderThe following four methods are provided:
-(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event-(
Seven gestures for IOS and seven gestures for IOS
Today, we will introduce seven types of gestures in IOS, which are often used in development. So let's talk about the seven gestures in
IOS gestures and ios gestures
In IOS, gestures can give users a good experience. Therefore, it is necessary to understand gestures.
(There are many notable points in setting
centerviewcontentrect = self.centerContainerView.frame; The original meaning is to place the gesture recognition of the trigger drawer on the entire screen.CGRect centerviewcontentrect = CGRectMake (0, 0, self.centerContainerView.frame.size.height); The modified meaning is to put the trigger open drawer gesture recognition on the left side of the screen width 50, high for the screen height of the rectCenterviewcontentrect = Cgrectintersection (centerviewcontentrect,self.childcontrollercontainer
Talking about gestures and touch in iOS, talking about iOS gesture touch
I. response chain
Various operation events will be encountered in IOS development, and these events can be responded through the program.
First, when an event responds, you must know who will respond to the event. In
nextresponder = [self nextresponder];if ([Nextresponder Iskindofclass:[uiviewcontroller class]]) {return nextresponder;} else if ([Nextresponder Iskindofclass:[uiview class]]) {return [Nextresponder Traverseresponderchainforuiviewcontroller];} else {return nil;}}Vi. Event DeliveryWhen a sub-view needs to receive a click event, its parent view also needs to receive the Click event, what to do with it:Under normal circumstances, when a subclass receives a click event, the event is not actively de
nextresponder = [self nextresponder];if ([Nextresponder Iskindofclass:[uiviewcontroller class]]) {return nextresponder;} else if ([Nextresponder Iskindofclass:[uiview class]]) {return [Nextresponder Traverseresponderchainforuiviewcontroller];} else {return nil;}}Vi. Event DeliveryWhen a sub-view needs to receive a click event, its parent view also needs to receive the Click event, what to do with it:Under normal circumstances, when a subclass receives a click event, the event is not actively de
Objective
In iOS, you can use the system's built-in gesture recognition (Gesturerecognizer), or you can create your own gestures. Gesturerecognizer converts low-level to high-level execution behavior, the object you bind to the view, and when a gesture occurs, the view object that is bound to it responds and determines whether the action corresponds to a particular gesture (swipe,pinch,pan,rotation If it
control is recorded as Hit-test view) and the touch event Touchesbegan is triggered. Also, if a control's gesture recognizer receives the touch, it is recognized. Gesture recognition succeeds after sending touch event touchescancelled to Hit-testview,hit-test view no longer responds to touch. * (2) Cancelstouchesinview:The default is yes, in which case the gesture recognizer sends a touchescancelled to Hit-testview to cancel the response of the Hit-test view to touch when it recognizes touch, a
*) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) Othergesturerecognizer3 {4 returnYES;5 }6 7 whether to allow triggering gestures to start8-(BOOL) Gesturerecognizershouldbegin: (Uigesturerecognizer *) Gesturerecognizer9 {Ten returnNO; One } A - whether to allow the touch of the phone to be received (can control the range of touch) --(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecog
Ios gestures are an indispensable part of ios development. However, you do not know the mechanism of ios gestures and events. So today I would like to share with you the corresponding mechanism of ios events.
First,
I. OverviewThe operation of touch screen in iphone, before 3.2 is mainly used by the following 4 ways of Uiresponder :-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event-(void) touchescancelled: (Nsset *) touches withevent: ( Uievent *) event-(void) touchesended: (Nsset *) touches withevent: (Uievent *) event-(void) touchesmoved: (Nsset *) touches W Ithevent: (Uievent *) eventBut this way of identifying different gestures is really a
= cgaffinetransformrotate(self. ImageView. Transform, sender. Rotation); Sender. rotation = 0; //Self.imageView.transform = Cgaffinetransformmakerotation (sender.rotation);}Long Press-(void) longpress: (uilongpressgesturerecognizer*) sender {// just want to start by executing a code that needs to determine the state of the gesture if (sender. state = = Uigesturerecognizerstatebegan) { NSLog(@ "longpress"); }} Swipe-(void) Swipe: (uiswipegesturerecognizer*) send
;Step Three: Add the gesture recognizer to the corresponding View on[Self.iconview Addgesturerecognizer:tap];Fourth step: The trigger of the listening gesture[Tap addtarget:self Action: @selector (Tapiconview:)];Event occurrence invokes the custom Tapiconview method.Note: You can get the view that was clicked through Tap.view.2, the agent of UITapGestureRecognizerSet the agent for UITapGestureRecognizer to be the controller that the UIView is located on, abide by the agent protocol uitapgesturer
Today for everyone to introduce the iOS seven gestures, gestures in the development of often used, so simple and easy to understand the next, words do not say, directly look at the code://initialize a uiimageview uiimageview *imageview = [[uiimageview Alloc]initwithframe:cgrectmake (100, 100, 300, 300)]; Imageview.image = [uiimage imagenamed: @ "12.jpg"]; //Uiima
Simple methods and gestures for creating arrays in iOS
In fact, outsourcing is also quite good. Although tired, the daily knowledge has been expanded a lot. The following are the gains of today.
① Method of initializing array-1 dictionary
@ [] Initializing an unchangeable Array
@ {} Initialize an unchangeable dictionary
② Use of gestures
In
SSL handshake failure resolution between IOS and Java server: Cipher SuitesThe beautiful Life of the Sun Vulcan (http://blog.csdn.net/opengl_es)This article follows "Attribution-non-commercial use-consistent" authoring public agreementReprint Please keep this sentence: Sun Vulcan's Beautiful Life-this blog focuses on Agile development and mobile and IoT device research: IOS, Android, HTML5, Arduino, Pcduino
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.